<template>
    <div class="container">
        <div class="flex-box-align" style="padding-bottom: 20px;border-bottom: 1px solid #f4f4f4">
            <div class="flex">新增开方荐药</div>
        </div>

        <ul class="medicine-info flex">
            <li>
                <span>姓名：</span>
                <span>{{name}}</span>
            </li>

            <li class="flex-box-align">
                <span>详情：</span>
                <el-input type="textarea" autosize style="width: 400px" v-model="detail" placeholder="请输入"></el-input>
            </li>
        </ul>
        <div style="margin-top: 40px;text-align: center;width:400px">
            <el-button type="primary" @click="handleClickSave">保存</el-button>
            <el-button type="primary" @click="$router.back(-1)">返回</el-button>
        </div>
    </div>
</template>

<script>
    let CONSTANT = require('../../constant/constant.js');
    let common = require("../../common.js");
    import {parseUrlParams} from "../../util";

    export default {
        data() {
            return {
                detail: "",
                name: ""
            }
        },
        components: {

        },
        mounted() {
            this.name = decodeURIComponent(parseUrlParams("name"))
        },
        methods: {
            handleClickSave() {
                if (!this.detail) {
                    this.$message.error('请输入详情');
                    return false
                }
                let params = {
                    detail: this.detail,
                    patientId: parseUrlParams("id")
                }
                common.requestAjax(CONSTANT.URL.PATIENT.MEDICINEEDIT, JSON.stringify(params), {}, (res) => {
                    if (res.status == 200) {
                        this.$message({
                            message: res.msg,
                            type: 'success'
                        });
                        this.$router.back(-1)
                    }

                })
            }
        }
    }
</script>

<style lang="scss">
    .container {
        .medicine-info {
            li {
                margin-top: 20px;
            }
            li>span:nth-child(1) {
                display: inline-block;
                width: 200px;
            }
        }
    }
</style>
